import { userGetUserInfoService } from "@/api/user"
import { defineStore } from "pinia"
import { ref } from 'vue'
// 用户模块
export const useUserStore = defineStore('big-user',()=>{
  const token = ref('')
  const setToken = (newToken) => {
    token.value = newToken
  }
  const removeToken = ()=>{
    token.value = ''
  }
  // 用户信息相关
  const userInfo =ref({})
  const getUserInfo =  async ()=>{
   const res = await userGetUserInfoService()
   userInfo.value = res.data.data
  }
  const setUserInfo = (userInfo)=>{
    userInfo.value = userInfo
  }
  const userDefaultAvatar = "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
  return {
    token,
    setToken,
    removeToken,
    userInfo,
    getUserInfo,
    setUserInfo,
    userDefaultAvatar

  }
},
{
  persist:true
}
)
